<?php

namespace App\Http\Model;

use App\Http\Model\Api\FinanceWallet;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;


class Medal extends Base
{
    protected $table = 'medal';
    protected $user_table = 'medal_user';

    public function __construct(array $attributes = [])
    {
        parent::__construct($this->table, $attributes);
    }

    /*
     * 获取用户勋章
     * @param $user_id
     * @param $medal_id
     * */

    public function getUserMedal($user_id, $medal_id = 0)
    {
        $where['user_id'] = $user_id;
        if ($medal_id != 0) {
            $where['medal_id'] = $medal_id;
        }
        $data = DB::connection('mysql_kkaudio')
            ->table($this->user_table)
            ->where($where)
            ->get();
        return $this->objToArray($data);

    }


}
